using UnityEngine;

namespace VoxelGame.World
{
	public class ChangeCameraCulling : MonoBehaviour
	{
		[SerializeField]
		private float _cullingFov = 80f;

		[SerializeField]
		private Camera _camera;

		private void Start()
		{
			if (_camera == null)
			{
				_camera = GetComponent<Camera>();
			}
		}

		private void OnPreCull()
		{
			_camera.projectionMatrix = Matrix4x4.Perspective(_cullingFov, _camera.aspect, _camera.nearClipPlane, _camera.farClipPlane);
		}

		private void OnPreRender()
		{
			_camera.ResetProjectionMatrix();
		}
	}
}
